﻿using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using StarsAdmin.Core.Helpers;
using System.Reflection;

namespace StarsAdmin.Web.Core.Extensions
{
    public static class AutoMapperExtension
    {
        public static void AddAutoMapperConfig(this IServiceCollection services)
        {
            Assembly assembly = AssemblyHelper.GetAssemblyByName("StarsAdmin.Application");
            var profiles = assembly.GetExportedTypes().Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Profile)));
            foreach (var profile in profiles)
            {
                services.AddAutoMapper(profile);
            }
        }
    }
}